package leetcode;

import org.springframework.web.bind.annotation.RequestBody;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author: Yangu
 * @Created time: 2021/2/1 23:26
 * @Description :
 */
public class 无重复字符的最长子串 {

    public int lengthOfLongestSubstring(String s) {

        int maxLength = 0;
        int tempLength = 0;
        for(int j=0; j<s.length(); j++) {
            Set set = new HashSet<>();
            for(int i=j; i<s.length(); i++) {
                char a = s.charAt(i);
                if(set.add(a)) {
                    tempLength = tempLength + 1;
                } else {
                    if(tempLength > maxLength) {
                        maxLength = tempLength;
                    }
                }

            }
        }
        return maxLength;
    }

    public static void main(String[] args) {

    }
}
